{% extends "pretixcontrol/admin/base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% load rich_text %}

{% block title %}{% trans "Social login settings" %}{% endblock %}
{% block content %}
    <nav id="event-nav" class="header-nav">
        <div class="navigation">
            <div class="navigation-title">
                <h1>{% trans "Social login settings" %}</h1>
            </div>
            {% include "pretixcontrol/event/component_link.html" %}
        </div>
    </nav>
    <form action="" method="post" class="form-horizontal form-plugins">
        {% csrf_token %}
        {% if "success" in request.GET %}
            <div class="alert alert-success">
                {% trans "Your changes have been saved." %}
            </div>
        {% endif %}
        <div class="tabbed-form">
            <fieldset>
                <legend>{% trans "Social login providers" %}</legend>
                <div class="table-responsive">
                    <table class="table">
                        {% for provider, settings in login_providers.items %}
                            <tr class="{% if settings.state %}success{% else %}default{% endif %}">
                                <td>
                                    {% with provider|capfirst as provider_capitalized %}
                                        <strong>{% trans provider_capitalized %}</strong>
                                        <p>{% blocktrans %}Login with {{ provider_capitalized }}{% endblocktrans %}</p>
                                    {% endwith %}
                                </td>
                                <td class="text-right flip" width="20%">
                                    {% if settings.state %}
                                        <button class="btn btn-default btn-block" name="{{ provider }}_login" value="disabled">
                                            {% trans "Disable" %}
                                        </button>
                                    {% else %}
                                        <button class="btn btn-default btn-block" name="{{ provider }}_login" value="enabled">
                                            {% trans "Enable" %}
                                        </button>
                                    {% endif %}
                                </td>
                            </tr>
                            {% if settings.state %}
                            <tr>
                                <td colspan="2">
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">
                                            {% if provider == "mediawiki" %}
                                                {% trans "Client Application Key" %}
                                            {% else %}
                                                {% trans "Client ID" %}
                                            {% endif %}
                                        </label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" name="{{ provider }}_client_id" value="{{ settings.client_id }}">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">
                                            {% if provider == "mediawiki" %}
                                                {% trans "Client Application Secret" %}
                                            {% else %}
                                                {% trans "Secret" %}
                                            {% endif %}
                                        </label>
                                        <div class="col-sm-9">
                                            <input type="password" class="form-control" name="{{ provider }}_secret" value="{{ settings.secret }}">
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            {% endif %}
                        {% endfor %}
                    </table>
                </div>
            </fieldset>
            <fieldset>
                {% include "socialauth/social_setup.html" %}
            </fieldset>
        </div>
        <div class="form-group submit-group">
            <button type="submit" class="btn btn-primary btn-save" name="save_credentials" value="credentials">
                {% trans "Save" %}
            </button>
        </div>
    </form>
{% endblock %}
